#!/bin/bash

set -e -u

ROOT=$(cd $(dirname $0)/.. && pwd)

$ROOT/dev/util/docker pull concourse/concourse

DEVDIR=/tmp/concourse-dev
KEYSDIR=$DEVDIR/keys

mkdir -p $KEYSDIR
cd $KEYSDIR

mkdir -p web worker

function keygen() {
  [ -f $1 ] || ssh-keygen -t rsa -f $1 -N ''
}

keygen ./web/host_key
keygen ./web/session_signing_key
keygen ./worker/worker_key

cp ./worker/worker_key.pub ./web/authorized_worker_keys
cp ./web/host_key.pub ./worker
